import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PasswordValidation {

    public static void main(String[] args) {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String inputPassword = "";
        int count = 0;

        try {
            for (int i = 1; i <= 5; i++) {
                System.out.print("请输入密码: ");
                inputPassword = br.readLine();
                if (inputPassword.equals("123456")) {
                    System.out.println("恭喜你进入游戏");
                    break;
                } else {
                    count++;
                    if (count == 5) {
                        System.out.println("密码错误，结束游戏");
                        System.exit(0);
                    } else {
                        System.out.println("密码错误，你还有" + (5 - count) + "次机会");
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
